<?php

namespace app\adminapi\export;

use app\services\product\product\StoreProductServices;

class StoreShippingExport extends BaseExport
{
    protected $header = [
        '商品', '分类', '价格(元)', '上下架状态', '经销商', '配送模版'
    ];

    public function createData(array $where)
    {
        $list = app()->make(StoreProductServices::class)->getShippingList($where)['list'];

        $data = [];
        foreach ($list as $item) {
            foreach ($item['distributor_shipping'] as $k1 => $item1) {
                $data[] = [
                    ($k1 == 0) ? $item['stock_name'] ?? '' : '',
                    ($k1 == 0) ? $item['cate_name'] ?? '' : '',
                    ($k1 == 0) ? $item['price'] ?? '' : '',
                    ($k1 == 0) ? ($item['is_show'] == 1 ? '上架' : '下架') : '',
                    $item1['distributor_name'],
                    $item1['template_name']
                ];
            }
        }

        return $data;
    }
}